<?php

require_once 'models/DAL/CategoriaDAO.php';
require_once 'models/DAL/LinhasDAO.php';

class Application_Model_DbTable_Categoria extends Zend_Db_Table_Abstract {

    protected $_name = 'Categoria';
    protected $_primary = 'idCategoria';
    protected $_referenceMap = array(
        'refProdutos' => array(
            'refTableClass' => 'Application_Model_DbTable_Produtos',
            'refColumns' => array('idCategoria'),
            'columns' => array('idCategoria')
        )
    );

    public function __construct($config = array()) {
        parent::__construct($config);    }

    /**
     * 
     * @return type
     */
    public function getAllCategorias() {
        
        $rows = $this->fetchAll();
        $return = array();

        foreach ($rows as $row) {
            $dao = new Application_Model_DAO_Categoria();
            $dao->setIdCategoria($row['idCategoria']);
            $dao->setCategoria($row['categoria']);
            $dao->setImagePath($row['imagePath']);
            $return[] = $dao;
        }

        return $return;
    }

}

